﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ninject;
using RoccaStore.Services;

namespace RoccaStore.Web.Filters
{
    public class AccountFilterAttribute : ActionFilterAttribute
    {
        [Inject]
        public IAccountService AccountService { get; set; }

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var result = filterContext.Result as ViewResult;

            if (result != null)
                result.ViewBag.Account = AccountService.Current;

            base.OnActionExecuted(filterContext);
        }
    }
}